<template>
  <el-avatar :style="{border:config.border? '3px solid #c0c4cc':''}" :src="imgUrl" v-bind="config" @error="$emit('error',$event)">
    <slot />
  </el-avatar>
</template>

<script>
export default {
  props: {
    src: {
      type: String,
      default: ''
    },
    config: {
      type: Object,
      default() {
        return {
          fit: 'cover'
        }
      }
    }
  },
  data() {
    return {
    }
  },
  computed: {
    imgUrl() {
      if (/http/.test(this.src)) {
        return this.src
      } else {
        return process.env.VUE_APP_IMG_BASE + this.src
      }
    }
  }
}
</script>

<style lang="scss" scoped>
::v-deep.el-avatar>img{
  width: 100%;
}
</style>
